grammar Amtscript;

options {
	superClass = AmtscriptANTLRParserBase;
	backtrack = true;
	memoize = true;
}

@lexer::header {
	package edu.pku.sei.AMT.resource.amtscript.mopp;
}

@lexer::members {
	public java.util.List<org.antlr.runtime3_4_0.RecognitionException> lexerExceptions  = new java.util.ArrayList<org.antlr.runtime3_4_0.RecognitionException>();
	public java.util.List<Integer> lexerExceptionsPosition = new java.util.ArrayList<Integer>();
	
	public void reportError(org.antlr.runtime3_4_0.RecognitionException e) {
		lexerExceptions.add(e);
		lexerExceptionsPosition.add(((org.antlr.runtime3_4_0.ANTLRStringStream) input).index());
	}
}
@header{
	package edu.pku.sei.AMT.resource.amtscript.mopp;
}

@members{
	private edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolverFactory tokenResolverFactory = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTokenResolverFactory();
	
	/**
	 * the index of the last token that was handled by collectHiddenTokens()
	 */
	private int lastPosition;
	
	/**
	 * A flag that indicates whether the parser should remember all expected elements.
	 * This flag is set to true when using the parse for code completion. Otherwise it
	 * is set to false.
	 */
	private boolean rememberExpectedElements = false;
	
	private Object parseToIndexTypeObject;
	private int lastTokenIndex = 0;
	
	/**
	 * A list of expected elements the were collected while parsing the input stream.
	 * This list is only filled if <code>rememberExpectedElements</code> is set to
	 * true.
	 */
	private java.util.List<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> expectedElements = new java.util.ArrayList<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal>();
	
	private int mismatchedTokenRecoveryTries = 0;
	/**
	 * A helper list to allow a lexer to pass errors to its parser
	 */
	protected java.util.List<org.antlr.runtime3_4_0.RecognitionException> lexerExceptions = java.util.Collections.synchronizedList(new java.util.ArrayList<org.antlr.runtime3_4_0.RecognitionException>());
	
	/**
	 * Another helper list to allow a lexer to pass positions of errors to its parser
	 */
	protected java.util.List<Integer> lexerExceptionsPosition = java.util.Collections.synchronizedList(new java.util.ArrayList<Integer>());
	
	/**
	 * A stack for incomplete objects. This stack is used filled when the parser is
	 * used for code completion. Whenever the parser starts to read an object it is
	 * pushed on the stack. Once the element was parser completely it is popped from
	 * the stack.
	 */
	java.util.List<org.eclipse.emf.ecore.EObject> incompleteObjects = new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
	
	private int stopIncludingHiddenTokens;
	private int stopExcludingHiddenTokens;
	private int tokenIndexOfLastCompleteElement;
	
	private int expectedElementsIndexOfLastCompleteElement;
	
	/**
	 * The offset indicating the cursor position when the parser is used for code
	 * completion by calling parseToExpectedElements().
	 */
	private int cursorOffset;
	
	/**
	 * The offset of the first hidden token of the last expected element. This offset
	 * is used to discard expected elements, which are not needed for code completion.
	 */
	private int lastStartIncludingHidden;
	
	protected void addErrorToResource(final String errorMessage, final int column, final int line, final int startIndex, final int stopIndex) {
		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
				if (resource == null) {
					// the resource can be null if the parser is used for code completion
					return true;
				}
				resource.addProblem(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptProblem() {
					public edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemSeverity getSeverity() {
						return edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemSeverity.ERROR;
					}
					public edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemType getType() {
						return edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemType.SYNTAX_ERROR;
					}
					public String getMessage() {
						return errorMessage;
					}
					public java.util.Collection<edu.pku.sei.AMT.resource.amtscript.IAmtscriptQuickFix> getQuickFixes() {
						return null;
					}
				}, column, line, startIndex, stopIndex);
				return true;
			}
		});
	}
	
	public void addExpectedElement(org.eclipse.emf.ecore.EClass eClass, int[] ids) {
		if (!this.rememberExpectedElements) {
			return;
		}
		int terminalID = ids[0];
		int followSetID = ids[1];
		edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement terminal = edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptFollowSetProvider.TERMINALS[terminalID];
		edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[] containmentFeatures = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[ids.length - 2];
		for (int i = 2; i < ids.length; i++) {
			containmentFeatures[i - 2] = edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptFollowSetProvider.LINKS[ids[i]];
		}
		edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace containmentTrace = new edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace(eClass, containmentFeatures);
		org.eclipse.emf.ecore.EObject container = getLastIncompleteElement();
		edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal expectedElement = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal(container, terminal, followSetID, containmentTrace);
		setPosition(expectedElement, input.index());
		int startIncludingHiddenTokens = expectedElement.getStartIncludingHiddenTokens();
		if (lastStartIncludingHidden >= 0 && lastStartIncludingHidden < startIncludingHiddenTokens && cursorOffset > startIncludingHiddenTokens) {
			// clear list of expected elements
			this.expectedElements.clear();
			this.expectedElementsIndexOfLastCompleteElement = 0;
		}
		lastStartIncludingHidden = startIncludingHiddenTokens;
		this.expectedElements.add(expectedElement);
	}
	
	protected void collectHiddenTokens(org.eclipse.emf.ecore.EObject element) {
	}
	
	protected void copyLocalizationInfos(final org.eclipse.emf.ecore.EObject source, final org.eclipse.emf.ecore.EObject target) {
		if (disableLocationMap) {
			return;
		}
		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptLocationMap locationMap = resource.getLocationMap();
				if (locationMap == null) {
					// the locationMap can be null if the parser is used for code completion
					return true;
				}
				locationMap.setCharStart(target, locationMap.getCharStart(source));
				locationMap.setCharEnd(target, locationMap.getCharEnd(source));
				locationMap.setColumn(target, locationMap.getColumn(source));
				locationMap.setLine(target, locationMap.getLine(source));
				return true;
			}
		});
	}
	
	protected void copyLocalizationInfos(final org.antlr.runtime3_4_0.CommonToken source, final org.eclipse.emf.ecore.EObject target) {
		if (disableLocationMap) {
			return;
		}
		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptLocationMap locationMap = resource.getLocationMap();
				if (locationMap == null) {
					// the locationMap can be null if the parser is used for code completion
					return true;
				}
				if (source == null) {
					return true;
				}
				locationMap.setCharStart(target, source.getStartIndex());
				locationMap.setCharEnd(target, source.getStopIndex());
				locationMap.setColumn(target, source.getCharPositionInLine());
				locationMap.setLine(target, source.getLine());
				return true;
			}
		});
	}
	
	/**
	 * Sets the end character index and the last line for the given object in the
	 * location map.
	 */
	protected void setLocalizationEnd(java.util.Collection<edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>> postParseCommands , final org.eclipse.emf.ecore.EObject object, final int endChar, final int endLine) {
		if (disableLocationMap) {
			return;
		}
		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptLocationMap locationMap = resource.getLocationMap();
				if (locationMap == null) {
					// the locationMap can be null if the parser is used for code completion
					return true;
				}
				locationMap.setCharEnd(object, endChar);
				locationMap.setLine(object, endLine);
				return true;
			}
		});
	}
	
	public edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextParser createInstance(java.io.InputStream actualInputStream, String encoding) {
		try {
			if (encoding == null) {
				return new AmtscriptParser(new org.antlr.runtime3_4_0.CommonTokenStream(new AmtscriptLexer(new org.antlr.runtime3_4_0.ANTLRInputStream(actualInputStream))));
			} else {
				return new AmtscriptParser(new org.antlr.runtime3_4_0.CommonTokenStream(new AmtscriptLexer(new org.antlr.runtime3_4_0.ANTLRInputStream(actualInputStream, encoding))));
			}
		} catch (java.io.IOException e) {
			new edu.pku.sei.AMT.resource.amtscript.util.AmtscriptRuntimeUtil().logError("Error while creating parser.", e);
			return null;
		}
	}
	
	/**
	 * This default constructor is only used to call createInstance() on it.
	 */
	public AmtscriptParser() {
		super(null);
	}
	
	protected org.eclipse.emf.ecore.EObject doParse() throws org.antlr.runtime3_4_0.RecognitionException {
		this.lastPosition = 0;
		// required because the lexer class can not be subclassed
		((AmtscriptLexer) getTokenStream().getTokenSource()).lexerExceptions = lexerExceptions;
		((AmtscriptLexer) getTokenStream().getTokenSource()).lexerExceptionsPosition = lexerExceptionsPosition;
		Object typeObject = getTypeObject();
		if (typeObject == null) {
			return start();
		} else if (typeObject instanceof org.eclipse.emf.ecore.EClass) {
			org.eclipse.emf.ecore.EClass type = (org.eclipse.emf.ecore.EClass) typeObject;
			if (type.getInstanceClass() == edu.pku.sei.AMT.Transformation.class) {
				return parse_edu_pku_sei_AMT_Transformation();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.TypedModel.class) {
				return parse_edu_pku_sei_AMT_TypedModel();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.Key.class) {
				return parse_edu_pku_sei_AMT_Key();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.Rule.class) {
				return parse_edu_pku_sei_AMT_Rule();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.ObjectVariable.class) {
				return parse_edu_pku_sei_AMT_ObjectVariable();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.PrimitiveVariable.class) {
				return parse_edu_pku_sei_AMT_PrimitiveVariable();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.Section.class) {
				return parse_edu_pku_sei_AMT_Section();
			}
			if (type.getInstanceClass() == edu.pku.sei.AMT.LinkConstraint.class) {
				return parse_edu_pku_sei_AMT_LinkConstraint();
			}
		}
		throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptUnexpectedContentTypeException(typeObject);
	}
	
	public int getMismatchedTokenRecoveryTries() {
		return mismatchedTokenRecoveryTries;
	}
	
	public Object getMissingSymbol(org.antlr.runtime3_4_0.IntStream arg0, org.antlr.runtime3_4_0.RecognitionException arg1, int arg2, org.antlr.runtime3_4_0.BitSet arg3) {
		mismatchedTokenRecoveryTries++;
		return super.getMissingSymbol(arg0, arg1, arg2, arg3);
	}
	
	public Object getParseToIndexTypeObject() {
		return parseToIndexTypeObject;
	}
	
	protected Object getTypeObject() {
		Object typeObject = getParseToIndexTypeObject();
		if (typeObject != null) {
			return typeObject;
		}
		java.util.Map<?,?> options = getOptions();
		if (options != null) {
			typeObject = options.get(edu.pku.sei.AMT.resource.amtscript.IAmtscriptOptions.RESOURCE_CONTENT_TYPE);
		}
		return typeObject;
	}
	
	/**
	 * Implementation that calls {@link #doParse()} and handles the thrown
	 * RecognitionExceptions.
	 */
	public edu.pku.sei.AMT.resource.amtscript.IAmtscriptParseResult parse() {
		terminateParsing = false;
		postParseCommands = new java.util.ArrayList<edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>>();
		edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptParseResult parseResult = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptParseResult();
		try {
			org.eclipse.emf.ecore.EObject result =  doParse();
			if (lexerExceptions.isEmpty()) {
				parseResult.setRoot(result);
			}
		} catch (org.antlr.runtime3_4_0.RecognitionException re) {
			reportError(re);
		} catch (java.lang.IllegalArgumentException iae) {
			if ("The 'no null' constraint is violated".equals(iae.getMessage())) {
				// can be caused if a null is set on EMF models where not allowed. this will just
				// happen if other errors occurred before
			} else {
				iae.printStackTrace();
			}
		}
		for (org.antlr.runtime3_4_0.RecognitionException re : lexerExceptions) {
			reportLexicalError(re);
		}
		parseResult.getPostParseCommands().addAll(postParseCommands);
		return parseResult;
	}
	
	public java.util.List<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> parseToExpectedElements(org.eclipse.emf.ecore.EClass type, edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource dummyResource, int cursorOffset) {
		this.rememberExpectedElements = true;
		this.parseToIndexTypeObject = type;
		this.cursorOffset = cursorOffset;
		this.lastStartIncludingHidden = -1;
		final org.antlr.runtime3_4_0.CommonTokenStream tokenStream = (org.antlr.runtime3_4_0.CommonTokenStream) getTokenStream();
		edu.pku.sei.AMT.resource.amtscript.IAmtscriptParseResult result = parse();
		for (org.eclipse.emf.ecore.EObject incompleteObject : incompleteObjects) {
			org.antlr.runtime3_4_0.Lexer lexer = (org.antlr.runtime3_4_0.Lexer) tokenStream.getTokenSource();
			int endChar = lexer.getCharIndex();
			int endLine = lexer.getLine();
			setLocalizationEnd(result.getPostParseCommands(), incompleteObject, endChar, endLine);
		}
		if (result != null) {
			org.eclipse.emf.ecore.EObject root = result.getRoot();
			if (root != null) {
				dummyResource.getContentsInternal().add(root);
			}
			for (edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource> command : result.getPostParseCommands()) {
				command.execute(dummyResource);
			}
		}
		// remove all expected elements that were added after the last complete element
		expectedElements = expectedElements.subList(0, expectedElementsIndexOfLastCompleteElement + 1);
		int lastFollowSetID = expectedElements.get(expectedElementsIndexOfLastCompleteElement).getFollowSetID();
		java.util.Set<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> currentFollowSet = new java.util.LinkedHashSet<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal>();
		java.util.List<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> newFollowSet = new java.util.ArrayList<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal>();
		for (int i = expectedElementsIndexOfLastCompleteElement; i >= 0; i--) {
			edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal expectedElementI = expectedElements.get(i);
			if (expectedElementI.getFollowSetID() == lastFollowSetID) {
				currentFollowSet.add(expectedElementI);
			} else {
				break;
			}
		}
		int followSetID = 65;
		int i;
		for (i = tokenIndexOfLastCompleteElement; i < tokenStream.size(); i++) {
			org.antlr.runtime3_4_0.CommonToken nextToken = (org.antlr.runtime3_4_0.CommonToken) tokenStream.get(i);
			if (nextToken.getType() < 0) {
				break;
			}
			if (nextToken.getChannel() == 99) {
				// hidden tokens do not reduce the follow set
			} else {
				// now that we have found the next visible token the position for that expected
				// terminals can be set
				for (edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal nextFollow : newFollowSet) {
					lastTokenIndex = 0;
					setPosition(nextFollow, i);
				}
				newFollowSet.clear();
				// normal tokens do reduce the follow set - only elements that match the token are
				// kept
				for (edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal nextFollow : currentFollowSet) {
					if (nextFollow.getTerminal().getTokenNames().contains(getTokenNames()[nextToken.getType()])) {
						// keep this one - it matches
						java.util.Collection<edu.pku.sei.AMT.resource.amtscript.util.AmtscriptPair<edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[]>> newFollowers = nextFollow.getTerminal().getFollowers();
						for (edu.pku.sei.AMT.resource.amtscript.util.AmtscriptPair<edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[]> newFollowerPair : newFollowers) {
							edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement newFollower = newFollowerPair.getLeft();
							org.eclipse.emf.ecore.EObject container = getLastIncompleteElement();
							edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace containmentTrace = new edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace(null, newFollowerPair.getRight());
							edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal newFollowTerminal = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal(container, newFollower, followSetID, containmentTrace);
							newFollowSet.add(newFollowTerminal);
							expectedElements.add(newFollowTerminal);
						}
					}
				}
				currentFollowSet.clear();
				currentFollowSet.addAll(newFollowSet);
			}
			followSetID++;
		}
		// after the last token in the stream we must set the position for the elements
		// that were added during the last iteration of the loop
		for (edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal nextFollow : newFollowSet) {
			lastTokenIndex = 0;
			setPosition(nextFollow, i);
		}
		return this.expectedElements;
	}
	
	public void setPosition(edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal expectedElement, int tokenIndex) {
		int currentIndex = Math.max(0, tokenIndex);
		for (int index = lastTokenIndex; index < currentIndex; index++) {
			if (index >= input.size()) {
				break;
			}
			org.antlr.runtime3_4_0.CommonToken tokenAtIndex = (org.antlr.runtime3_4_0.CommonToken) input.get(index);
			stopIncludingHiddenTokens = tokenAtIndex.getStopIndex() + 1;
			if (tokenAtIndex.getChannel() != 99 && !anonymousTokens.contains(tokenAtIndex)) {
				stopExcludingHiddenTokens = tokenAtIndex.getStopIndex() + 1;
			}
		}
		lastTokenIndex = Math.max(0, currentIndex);
		expectedElement.setPosition(stopExcludingHiddenTokens, stopIncludingHiddenTokens);
	}
	
	public Object recoverFromMismatchedToken(org.antlr.runtime3_4_0.IntStream input, int ttype, org.antlr.runtime3_4_0.BitSet follow) throws org.antlr.runtime3_4_0.RecognitionException {
		if (!rememberExpectedElements) {
			return super.recoverFromMismatchedToken(input, ttype, follow);
		} else {
			return null;
		}
	}
	
	/**
	 * Translates errors thrown by the parser into human readable messages.
	 */
	public void reportError(final org.antlr.runtime3_4_0.RecognitionException e)  {
		String message = e.getMessage();
		if (e instanceof org.antlr.runtime3_4_0.MismatchedTokenException) {
			org.antlr.runtime3_4_0.MismatchedTokenException mte = (org.antlr.runtime3_4_0.MismatchedTokenException) e;
			String expectedTokenName = formatTokenName(mte.expecting);
			String actualTokenName = formatTokenName(e.token.getType());
			message = "Syntax error on token \"" + e.token.getText() + " (" + actualTokenName + ")\", \"" + expectedTokenName + "\" expected";
		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedTreeNodeException) {
			org.antlr.runtime3_4_0.MismatchedTreeNodeException mtne = (org.antlr.runtime3_4_0.MismatchedTreeNodeException) e;
			String expectedTokenName = formatTokenName(mtne.expecting);
			message = "mismatched tree node: " + "xxx" + "; tokenName " + expectedTokenName;
		} else if (e instanceof org.antlr.runtime3_4_0.NoViableAltException) {
			message = "Syntax error on token \"" + e.token.getText() + "\", check following tokens";
		} else if (e instanceof org.antlr.runtime3_4_0.EarlyExitException) {
			message = "Syntax error on token \"" + e.token.getText() + "\", delete this token";
		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedSetException) {
			org.antlr.runtime3_4_0.MismatchedSetException mse = (org.antlr.runtime3_4_0.MismatchedSetException) e;
			message = "mismatched token: " + e.token + "; expecting set " + mse.expecting;
		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedNotSetException) {
			org.antlr.runtime3_4_0.MismatchedNotSetException mse = (org.antlr.runtime3_4_0.MismatchedNotSetException) e;
			message = "mismatched token: " +  e.token + "; expecting set " + mse.expecting;
		} else if (e instanceof org.antlr.runtime3_4_0.FailedPredicateException) {
			org.antlr.runtime3_4_0.FailedPredicateException fpe = (org.antlr.runtime3_4_0.FailedPredicateException) e;
			message = "rule " + fpe.ruleName + " failed predicate: {" +  fpe.predicateText + "}?";
		}
		// the resource may be null if the parser is used for code completion
		final String finalMessage = message;
		if (e.token instanceof org.antlr.runtime3_4_0.CommonToken) {
			final org.antlr.runtime3_4_0.CommonToken ct = (org.antlr.runtime3_4_0.CommonToken) e.token;
			addErrorToResource(finalMessage, ct.getCharPositionInLine(), ct.getLine(), ct.getStartIndex(), ct.getStopIndex());
		} else {
			addErrorToResource(finalMessage, e.token.getCharPositionInLine(), e.token.getLine(), 1, 5);
		}
	}
	
	/**
	 * Translates errors thrown by the lexer into human readable messages.
	 */
	public void reportLexicalError(final org.antlr.runtime3_4_0.RecognitionException e)  {
		String message = "";
		if (e instanceof org.antlr.runtime3_4_0.MismatchedTokenException) {
			org.antlr.runtime3_4_0.MismatchedTokenException mte = (org.antlr.runtime3_4_0.MismatchedTokenException) e;
			message = "Syntax error on token \"" + ((char) e.c) + "\", \"" + (char) mte.expecting + "\" expected";
		} else if (e instanceof org.antlr.runtime3_4_0.NoViableAltException) {
			message = "Syntax error on token \"" + ((char) e.c) + "\", delete this token";
		} else if (e instanceof org.antlr.runtime3_4_0.EarlyExitException) {
			org.antlr.runtime3_4_0.EarlyExitException eee = (org.antlr.runtime3_4_0.EarlyExitException) e;
			message = "required (...)+ loop (decision=" + eee.decisionNumber + ") did not match anything; on line " + e.line + ":" + e.charPositionInLine + " char=" + ((char) e.c) + "'";
		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedSetException) {
			org.antlr.runtime3_4_0.MismatchedSetException mse = (org.antlr.runtime3_4_0.MismatchedSetException) e;
			message = "mismatched char: '" + ((char) e.c) + "' on line " + e.line + ":" + e.charPositionInLine + "; expecting set " + mse.expecting;
		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedNotSetException) {
			org.antlr.runtime3_4_0.MismatchedNotSetException mse = (org.antlr.runtime3_4_0.MismatchedNotSetException) e;
			message = "mismatched char: '" + ((char) e.c) + "' on line " + e.line + ":" + e.charPositionInLine + "; expecting set " + mse.expecting;
		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedRangeException) {
			org.antlr.runtime3_4_0.MismatchedRangeException mre = (org.antlr.runtime3_4_0.MismatchedRangeException) e;
			message = "mismatched char: '" + ((char) e.c) + "' on line " + e.line + ":" + e.charPositionInLine + "; expecting set '" + (char) mre.a + "'..'" + (char) mre.b + "'";
		} else if (e instanceof org.antlr.runtime3_4_0.FailedPredicateException) {
			org.antlr.runtime3_4_0.FailedPredicateException fpe = (org.antlr.runtime3_4_0.FailedPredicateException) e;
			message = "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?";
		}
		addErrorToResource(message, e.charPositionInLine, e.line, lexerExceptionsPosition.get(lexerExceptions.indexOf(e)), lexerExceptionsPosition.get(lexerExceptions.indexOf(e)));
	}
	
	private void startIncompleteElement(Object object) {
		if (object instanceof org.eclipse.emf.ecore.EObject) {
			this.incompleteObjects.add((org.eclipse.emf.ecore.EObject) object);
		}
	}
	
	private void completedElement(Object object, boolean isContainment) {
		if (isContainment && !this.incompleteObjects.isEmpty()) {
			boolean exists = this.incompleteObjects.remove(object);
			if (!exists) {
			}
		}
		if (object instanceof org.eclipse.emf.ecore.EObject) {
			this.tokenIndexOfLastCompleteElement = getTokenStream().index();
			this.expectedElementsIndexOfLastCompleteElement = expectedElements.size() - 1;
		}
	}
	
	private org.eclipse.emf.ecore.EObject getLastIncompleteElement() {
		if (incompleteObjects.isEmpty()) {
			return null;
		}
		return incompleteObjects.get(incompleteObjects.size() - 1);
	}
	
}

start returns [ org.eclipse.emf.ecore.EObject element = null]
:
	{
		// follow set for start rule(s)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[0]);
		expectedElementsIndexOfLastCompleteElement = 0;
	}
	(
		c0 = parse_edu_pku_sei_AMT_Transformation{ element = c0; }
	)
	EOF	{
		retrieveLayoutInformation(element, null, null, false);
	}
	
;

parse_edu_pku_sei_AMT_Transformation returns [edu.pku.sei.AMT.Transformation element = null]
@init{
}
:
	a0 = 'transformation' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_0, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a0, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[1]);
	}
	
	(
		a1 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
				startIncompleteElement(element);
			}
			if (a1 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a1.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a1).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_1, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a1, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[2]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[3]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[4]);
	}
	
	(
		(
			(
				a2_0 = parse_edu_pku_sei_AMT_TypedModel				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
						startIncompleteElement(element);
					}
					if (a2_0 != null) {
						if (a2_0 != null) {
							Object value = a2_0;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__PARAMETERS, value);
							completedElement(value, true);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_2_0_0_0, a2_0, true);
						copyLocalizationInfos(a2_0, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[5]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[6]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[7]);
			}
			
			(
				(
					a3 = ',' {
						if (element == null) {
							element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
							startIncompleteElement(element);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_2_0_0_1_0_0_0, null, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
					}
					{
						// expected elements (follow set)
						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[8]);
					}
					
					(
						a4_0 = parse_edu_pku_sei_AMT_TypedModel						{
							if (terminateParsing) {
								throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
							}
							if (element == null) {
								element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
								startIncompleteElement(element);
							}
							if (a4_0 != null) {
								if (a4_0 != null) {
									Object value = a4_0;
									addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__PARAMETERS, value);
									completedElement(value, true);
								}
								collectHiddenTokens(element);
								retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_2_0_0_1_0_0_1, a4_0, true);
								copyLocalizationInfos(a4_0, element);
							}
						}
					)
					{
						// expected elements (follow set)
						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[9]);
						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[10]);
						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[11]);
					}
					
				)
				
			)*			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[12]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[13]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[14]);
			}
			
		)
		
	)?	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[15]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[16]);
	}
	
	(
		(
			a5_0 = parse_edu_pku_sei_AMT_Key			{
				if (terminateParsing) {
					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
				}
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
					startIncompleteElement(element);
				}
				if (a5_0 != null) {
					if (a5_0 != null) {
						Object value = a5_0;
						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__KEYS, value);
						completedElement(value, true);
					}
					collectHiddenTokens(element);
					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_3, a5_0, true);
					copyLocalizationInfos(a5_0, element);
				}
			}
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[17]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[18]);
	}
	
	(
		(
			a6_0 = parse_edu_pku_sei_AMT_Rule			{
				if (terminateParsing) {
					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
				}
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
					startIncompleteElement(element);
				}
				if (a6_0 != null) {
					if (a6_0 != null) {
						Object value = a6_0;
						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__RULES, value);
						completedElement(value, true);
					}
					collectHiddenTokens(element);
					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_4, a6_0, true);
					copyLocalizationInfos(a6_0, element);
				}
			}
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[19]);
	}
	
;

parse_edu_pku_sei_AMT_TypedModel returns [edu.pku.sei.AMT.TypedModel element = null]
@init{
}
:
	(
		a0 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTypedModel();
				startIncompleteElement(element);
			}
			if (a0 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_1_0_0_0, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[20]);
	}
	
	a1 = ':' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTypedModel();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_1_0_0_1, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[21]);
	}
	
	(
		a2 = URI		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTypedModel();
				startIncompleteElement(element);
			}
			if (a2 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("URI");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__URI), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__URI), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_1_0_0_2, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[22]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[23]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[24]);
	}
	
;

parse_edu_pku_sei_AMT_Key returns [edu.pku.sei.AMT.Key element = null]
@init{
}
:
	a0 = 'key' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_0, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a0, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[25]);
	}
	
	(
		a1 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
				startIncompleteElement(element);
			}
			if (a1 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a1.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.KEY__CLASS_NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a1).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.KEY__CLASS_NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_1, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a1, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[26]);
	}
	
	a2 = ':' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_2, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a2, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[27]);
	}
	
	(
		(
			(
				a3 = KEYFEATURENAME				
				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
						startIncompleteElement(element);
					}
					if (a3 != null) {
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("KEYFEATURENAME");
						tokenResolver.setOptions(getOptions());
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
						tokenResolver.resolve(a3.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.KEY__FEATURE_NAMES), result);
						Object resolvedObject = result.getResolvedToken();
						if (resolvedObject == null) {
							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a3).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a3).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a3).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a3).getStopIndex());
						}
						java.lang.String resolved = (java.lang.String) resolvedObject;
						if (resolved != null) {
							Object value = resolved;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.KEY__FEATURE_NAMES, value);
							completedElement(value, false);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_3_0_0_0, resolved, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a3, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[28]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[29]);
			}
			
		)
		
	)+	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[30]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[31]);
	}
	
	a4 = ';' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_4, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a4, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[32]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[33]);
	}
	
;

parse_edu_pku_sei_AMT_Rule returns [edu.pku.sei.AMT.Rule element = null]
@init{
}
:
	a0 = 'rule' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_0, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a0, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[34]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[35]);
	}
	
	(
		(
			(
				a1 = IDENTIFIER				
				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
						startIncompleteElement(element);
					}
					if (a1 != null) {
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
						tokenResolver.setOptions(getOptions());
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
						tokenResolver.resolve(a1.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.RULE__MODIFIERS), result);
						Object resolvedObject = result.getResolvedToken();
						if (resolvedObject == null) {
							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a1).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStopIndex());
						}
						java.lang.String resolved = (java.lang.String) resolvedObject;
						if (resolved != null) {
							Object value = resolved;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.RULE__MODIFIERS, value);
							completedElement(value, false);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_1_0_0_0, resolved, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a1, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[36]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[37]);
			}
			
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[38]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[39]);
	}
	
	(
		a2 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
				startIncompleteElement(element);
			}
			if (a2 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.RULE__NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.RULE__NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_2, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[40]);
	}
	
	a3 = '{' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_3, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[41]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[42]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[43]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[44]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[45]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[46]);
	}
	
	(
		(
			(
				a4_0 = parse_edu_pku_sei_AMT_Variable				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
						startIncompleteElement(element);
					}
					if (a4_0 != null) {
						if (a4_0 != null) {
							Object value = a4_0;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.RULE__VARIABLES, value);
							completedElement(value, true);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_4_0_0_0, a4_0, true);
						copyLocalizationInfos(a4_0, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[47]);
			}
			
			a5 = ';' {
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
					startIncompleteElement(element);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_4_0_0_1, null, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a5, element);
			}
			{
				// expected elements (follow set)
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[48]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[49]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[50]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[51]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[52]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[53]);
			}
			
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[54]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[55]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[56]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[57]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[58]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[59]);
	}
	
	(
		(
			a6_0 = parse_edu_pku_sei_AMT_Section			{
				if (terminateParsing) {
					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
				}
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
					startIncompleteElement(element);
				}
				if (a6_0 != null) {
					if (a6_0 != null) {
						Object value = a6_0;
						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.RULE__SECTIONS, value);
						completedElement(value, true);
					}
					collectHiddenTokens(element);
					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_5, a6_0, true);
					copyLocalizationInfos(a6_0, element);
				}
			}
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[60]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[61]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[62]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[63]);
	}
	
	a7 = '}' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_6, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a7, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[64]);
	}
	
;

parse_edu_pku_sei_AMT_ObjectVariable returns [edu.pku.sei.AMT.ObjectVariable element = null]
@init{
}
:
	(
		a0 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
				startIncompleteElement(element);
			}
			if (a0 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_0, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[65]);
	}
	
	a1 = ':' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_1, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[66]);
	}
	
	(
		a2 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
				startIncompleteElement(element);
			}
			if (a2 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__SCOPE), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__SCOPE), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_2, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[67]);
	}
	
	a3 = '::' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_3, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[68]);
	}
	
	(
		a4 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
				startIncompleteElement(element);
			}
			if (a4 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a4.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__TYPE), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a4).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__TYPE), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_4, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[69]);
	}
	
;

parse_edu_pku_sei_AMT_PrimitiveVariable returns [edu.pku.sei.AMT.PrimitiveVariable element = null]
@init{
}
:
	(
		a0 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
				startIncompleteElement(element);
			}
			if (a0 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_5_0_0_0, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[70]);
	}
	
	a1 = ':' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_5_0_0_1, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[71]);
	}
	
	(
		a2 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
				startIncompleteElement(element);
			}
			if (a2 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__TYPE), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__TYPE), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_5_0_0_2, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[72]);
	}
	
;

parse_edu_pku_sei_AMT_Section returns [edu.pku.sei.AMT.Section element = null]
@init{
}
:
	(
		(
			(
				a0 = IDENTIFIER				
				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
						startIncompleteElement(element);
					}
					if (a0 != null) {
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
						tokenResolver.setOptions(getOptions());
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
						tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__MODIFIERS), result);
						Object resolvedObject = result.getResolvedToken();
						if (resolvedObject == null) {
							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
						}
						java.lang.String resolved = (java.lang.String) resolvedObject;
						if (resolved != null) {
							Object value = resolved;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__MODIFIERS, value);
							completedElement(value, false);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_0_0_0_0, resolved, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[73]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[74]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[75]);
			}
			
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[76]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[77]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[78]);
	}
	
	(
		(
			a1 = 'for' {
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
					startIncompleteElement(element);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_1_0_0_0, null, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
			}
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[79]);
			}
			
			(
				a2 = IDENTIFIER				
				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
						startIncompleteElement(element);
					}
					if (a2 != null) {
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
						tokenResolver.setOptions(getOptions());
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
						tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__MODEL_NAME), result);
						Object resolvedObject = result.getResolvedToken();
						if (resolvedObject == null) {
							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
						}
						java.lang.String resolved = (java.lang.String) resolvedObject;
						if (resolved != null) {
							Object value = resolved;
							element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__MODEL_NAME), value);
							completedElement(value, false);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_1_0_0_1, resolved, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[80]);
			}
			
		)
		
	)?	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[81]);
	}
	
	a3 = '{' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_2, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[82]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[83]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[84]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[85]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[86]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[87]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[88]);
	}
	
	(
		(
			(
				a4 = IDENTIFIER				
				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
						startIncompleteElement(element);
					}
					if (a4 != null) {
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
						tokenResolver.setOptions(getOptions());
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
						tokenResolver.resolve(a4.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), result);
						Object resolvedObject = result.getResolvedToken();
						if (resolvedObject == null) {
							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a4).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStopIndex());
						}
						String resolved = (String) resolvedObject;
						edu.pku.sei.AMT.Variable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
						collectHiddenTokens(element);
						registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.Section, edu.pku.sei.AMT.Variable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getSectionReferredVariablesReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), resolved, proxy);
						if (proxy != null) {
							Object value = proxy;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES, value);
							completedElement(value, false);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_0, proxy, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, element);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, proxy);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[89]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[90]);
			}
			
			(
				(
					a5 = ',' {
						if (element == null) {
							element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
							startIncompleteElement(element);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_1_0_0_0, null, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a5, element);
					}
					{
						// expected elements (follow set)
						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[91]);
					}
					
					(
						a6 = IDENTIFIER						
						{
							if (terminateParsing) {
								throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
							}
							if (element == null) {
								element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
								startIncompleteElement(element);
							}
							if (a6 != null) {
								edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
								tokenResolver.setOptions(getOptions());
								edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
								tokenResolver.resolve(a6.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), result);
								Object resolvedObject = result.getResolvedToken();
								if (resolvedObject == null) {
									addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a6).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a6).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a6).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a6).getStopIndex());
								}
								String resolved = (String) resolvedObject;
								edu.pku.sei.AMT.Variable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
								collectHiddenTokens(element);
								registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.Section, edu.pku.sei.AMT.Variable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getSectionReferredVariablesReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), resolved, proxy);
								if (proxy != null) {
									Object value = proxy;
									addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES, value);
									completedElement(value, false);
								}
								collectHiddenTokens(element);
								retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_1_0_0_1, proxy, true);
								copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a6, element);
								copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a6, proxy);
							}
						}
					)
					{
						// expected elements (follow set)
						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[92]);
						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[93]);
					}
					
				)
				
			)*			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[94]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[95]);
			}
			
			a7 = ';' {
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
					startIncompleteElement(element);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_2, null, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a7, element);
			}
			{
				// expected elements (follow set)
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[96]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[97]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[98]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[99]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[100]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[101]);
			}
			
		)
		
	)?	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[102]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[103]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[104]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[105]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[106]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[107]);
	}
	
	(
		(
			(
				a8_0 = parse_edu_pku_sei_AMT_LinkConstraint				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
						startIncompleteElement(element);
					}
					if (a8_0 != null) {
						if (a8_0 != null) {
							Object value = a8_0;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__LINKS, value);
							completedElement(value, true);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_0, a8_0, true);
						copyLocalizationInfos(a8_0, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[108]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[109]);
			}
			
			(
				(
					a9 = ',' {
						if (element == null) {
							element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
							startIncompleteElement(element);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_1_0_0_0, null, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a9, element);
					}
					{
						// expected elements (follow set)
						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[110]);
					}
					
					(
						a10_0 = parse_edu_pku_sei_AMT_LinkConstraint						{
							if (terminateParsing) {
								throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
							}
							if (element == null) {
								element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
								startIncompleteElement(element);
							}
							if (a10_0 != null) {
								if (a10_0 != null) {
									Object value = a10_0;
									addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__LINKS, value);
									completedElement(value, true);
								}
								collectHiddenTokens(element);
								retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_1_0_0_1, a10_0, true);
								copyLocalizationInfos(a10_0, element);
							}
						}
					)
					{
						// expected elements (follow set)
						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[111]);
						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[112]);
					}
					
				)
				
			)*			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[113]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[114]);
			}
			
			a11 = ';' {
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
					startIncompleteElement(element);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_2, null, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a11, element);
			}
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[115]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[116]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[117]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[118]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[119]);
			}
			
		)
		
	)?	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[120]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[121]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[122]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[123]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[124]);
	}
	
	(
		(
			(
				a12 = EXPR				
				{
					if (terminateParsing) {
						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
					}
					if (element == null) {
						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
						startIncompleteElement(element);
					}
					if (a12 != null) {
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("EXPR");
						tokenResolver.setOptions(getOptions());
						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
						tokenResolver.resolve(a12.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__EXPRESSIONS), result);
						Object resolvedObject = result.getResolvedToken();
						if (resolvedObject == null) {
							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a12).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a12).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a12).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a12).getStopIndex());
						}
						java.lang.String resolved = (java.lang.String) resolvedObject;
						if (resolved != null) {
							Object value = resolved;
							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__EXPRESSIONS, value);
							completedElement(value, false);
						}
						collectHiddenTokens(element);
						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_5_0_0_0, resolved, true);
						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a12, element);
					}
				}
			)
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[125]);
			}
			
			a13 = ';' {
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
					startIncompleteElement(element);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_5_0_0_1, null, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a13, element);
			}
			{
				// expected elements (follow set)
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[126]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[127]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[128]);
				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[129]);
				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[130]);
			}
			
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[131]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[132]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[133]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[134]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[135]);
	}
	
	(
		(
			a14_0 = parse_edu_pku_sei_AMT_Section			{
				if (terminateParsing) {
					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
				}
				if (element == null) {
					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
					startIncompleteElement(element);
				}
				if (a14_0 != null) {
					if (a14_0 != null) {
						Object value = a14_0;
						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__SECTIONS, value);
						completedElement(value, true);
					}
					collectHiddenTokens(element);
					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_6, a14_0, true);
					copyLocalizationInfos(a14_0, element);
				}
			}
		)
		
	)*	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[136]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[137]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[138]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[139]);
	}
	
	a15 = '}' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_7, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a15, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[140]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[141]);
		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[142]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[143]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[144]);
	}
	
;

parse_edu_pku_sei_AMT_LinkConstraint returns [edu.pku.sei.AMT.LinkConstraint element = null]
@init{
}
:
	(
		a0 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
				startIncompleteElement(element);
			}
			if (a0 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__SOURCE), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
				}
				String resolved = (String) resolvedObject;
				edu.pku.sei.AMT.ObjectVariable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
				collectHiddenTokens(element);
				registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.LinkConstraint, edu.pku.sei.AMT.ObjectVariable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getLinkConstraintSourceReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__SOURCE), resolved, proxy);
				if (proxy != null) {
					Object value = proxy;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__SOURCE), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_0, proxy, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, proxy);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[145]);
	}
	
	a1 = '.' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_1, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[146]);
	}
	
	(
		a2 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
				startIncompleteElement(element);
			}
			if (a2 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__REF_NAME), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
				}
				java.lang.String resolved = (java.lang.String) resolvedObject;
				if (resolved != null) {
					Object value = resolved;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__REF_NAME), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_2, resolved, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[147]);
	}
	
	a3 = '=' {
		if (element == null) {
			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
			startIncompleteElement(element);
		}
		collectHiddenTokens(element);
		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_3, null, true);
		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
	}
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[148]);
	}
	
	(
		a4 = IDENTIFIER		
		{
			if (terminateParsing) {
				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
			}
			if (element == null) {
				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
				startIncompleteElement(element);
			}
			if (a4 != null) {
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
				tokenResolver.setOptions(getOptions());
				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
				tokenResolver.resolve(a4.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__TARGET), result);
				Object resolvedObject = result.getResolvedToken();
				if (resolvedObject == null) {
					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a4).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStopIndex());
				}
				String resolved = (String) resolvedObject;
				edu.pku.sei.AMT.ObjectVariable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
				collectHiddenTokens(element);
				registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.LinkConstraint, edu.pku.sei.AMT.ObjectVariable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getLinkConstraintTargetReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__TARGET), resolved, proxy);
				if (proxy != null) {
					Object value = proxy;
					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__TARGET), value);
					completedElement(value, false);
				}
				collectHiddenTokens(element);
				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_4, proxy, true);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, element);
				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, proxy);
			}
		}
	)
	{
		// expected elements (follow set)
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[149]);
		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[150]);
	}
	
;

parse_edu_pku_sei_AMT_Variable returns [edu.pku.sei.AMT.Variable element = null]
:
	c0 = parse_edu_pku_sei_AMT_ObjectVariable{ element = c0; /* this is a subclass or primitive expression choice */ }
	|	c1 = parse_edu_pku_sei_AMT_PrimitiveVariable{ element = c1; /* this is a subclass or primitive expression choice */ }
	
;

IDENTIFIER:
	(('A'..'Z'|'a'..'z'|'_')('_'|'A'..'Z'|'a'..'z'|'0'..'9')*)
;
KEYFEATURENAME:
	(('!'|'@')('A'..'Z'|'a'..'z'|'_')('_'|'A'..'Z'|'a'..'z'|'0'..'9')*)
;
URI:
	('<'('A'..'Z'|'a'..'z'|'0'..'9'|'/'|'\\'|':'|'.')+'>')
;
EXPR:
	('['(' '|'A'..'Z'|'a'..'z'|'0'..'9'|'_'|'-'|'+'|'*'|'/'|'='|'>'|'<'|'!'|'('|')'|'{'|'}'|':'|'\''|'\|'|','|'.')+']')
;
LINEBREAK:
	(('\r\n'|'\r'|'\n'))
	{ _channel = 99; }
;
WHITESPACE:
	((' '|'\t'|'\f'))
	{ _channel = 99; }
;

